import axios from 'axios';
axios.defaults.baseURL = "http://127.0.0.1:3000/";
//让axios允许设置cookie 并携带cookie请求服务器
axios.defaults.withCredentials = true


//登入接口
export const loginPost = params => {
    //POST参数处理
    let param = new URLSearchParams()
    param.append('userName', params.userName)
    param.append('password', params.password)
    return axios({
        url: '/users/login',
        method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        data: param
    }).then(res => res)
}
//退出接口
export const quit = () => {
    return axios({
        url: '/users/quit',
        method: 'get'
    }).then(res => res)
}

//验证是否登入

export const isLogin = () => {
    return axios({
        url: '/users/isLogin',
        method: 'post'
    }).then(res => res).catch(err=>{alert("连接出错")})
}


